﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MathLab.Utils
{
  class MatrixFactorMultiply
  {
    /// <summary>
    /// Multiply matrix by factor
    /// </summary>
    /// <param name="matrix">two-dimension array</param>
    /// <param name="factor"></param>
    /// <returns>matrix</returns>
    public static double[,] FactorMultiply(double[,] matrix, double factor)
    {
      double[,] matrixResult = new double[matrix.GetLength(0),matrix.GetLength(1)];
      for (int i = 0; i < matrix.GetLength(0); i++)
      {
        for (int j = 0; j < matrix.GetLength(1); j++)
        {
          matrixResult[i, j] = matrix[i,j] * factor;
        }
      }
      return matrixResult;
    }
    /// <summary>
    /// Multiply vector by factor
    /// </summary>
    /// <param name="vector">one-dimension array</param>
    /// <param name="factor"></param>
    /// <returns>vector</returns>
    public static double[] FactorMultiply(double[] vector, double factor)
    {
      double[] matrixResult = new double[vector.GetLength(0)];
      for (int i = 0; i < vector.GetLength(0); i++)
      {
        matrixResult[i] = vector[i] * factor;
      }
      return matrixResult;
    }
  }
}
